<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var reg = /[0-9]+/g;
    var s = 'aa我今年119岁了,结过3次婚,有18个孩子';
//    var r = reg.exec(s);
//    console.log(r);
//    var r = reg.exec(s);
//    console.log(r);
    var arr = [];
    function matchAllNum(reg,s){
        var tmp = reg.exec(s);
        //没次只找一个，但是会更新 reg.lastIndex

            if (tmp){
                arr.push(tmp[0]);
                matchAllNum(reg,s)
            }
    }

    matchAllNum(reg,s);
    console.log(arr);
</script>
</body>
</html>